<template>
  <div class="app-container">
    <div class="handle-content">
      <el-input v-if="this.$store.getters.role.store_id == 0" v-model="storeId" placeholder="请输入店铺id" style="width: 300px;margin-right: 10px;">
        <el-button slot="append" @click="search">{{text}}</el-button>
      </el-input>
    </div>

    <el-table v-loading="listLoading" :data="list" element-loading-text="拼命加载中" border fit highlight-current-row>
      <el-table-column v-if="this.$store.getters.role.store_id == 0" label="店铺ID" align="center">
        <template slot-scope="scope">
          {{ scope.row.store_id }}
        </template>
      </el-table-column>
      <el-table-column v-if="this.$store.getters.role.store_id == 0" label="店铺名称" align="center">
        <template slot-scope="scope">
          {{ scope.row.title }}
        </template>
      </el-table-column>
      <el-table-column label="会员ID" align="center">
        <template slot-scope="scope">
          {{ scope.row.id }}
        </template>
      </el-table-column>
      <el-table-column label="名字" align="center">
        <template slot-scope="scope">
          {{ scope.row.nickname }}
        </template>
      </el-table-column>
      <el-table-column label="手机" align="center">
        <template slot-scope="scope">
          {{ scope.row.phone }}
        </template>
      </el-table-column>
      <el-table-column label="余额" align="center">
        <template slot-scope="scope">
          {{ scope.row.gold / 100 }}
        </template>
      </el-table-column>
      <el-table-column label="累计余额" align="center">
        <template slot-scope="scope">
          {{ scope.row.end / 100}}
        </template>
      </el-table-column>
      <el-table-column label="记录最终余额" align="center">
        <template slot-scope="scope">
          {{ scope.row.last / 100 }}
        </template>
      </el-table-column>
      <el-table-column label="偏差" align="center">
        <template slot-scope="scope">
          {{ scope.row.diff }}
        </template>
      </el-table-column>
      <el-table-column label="注册时间" align="center">
        <template slot-scope="scope">
          {{ scope.row.regist_at }}
        </template>
      </el-table-column>
    </el-table>
    <pagination v-if="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.pageSize" @pagination="getList" />
  </div>
</template>
<script>
import Pagination from '@/components/Pagination' // Secondary package based on el-pagination
import { reviewAmount } from '@/api/deal'

export default {

  components: { Pagination },

  data() {
    return {
      showOrderInfo: false,
      list: [],
      listLoading: false,
      listQuery: {
        page: 1,
        storeId: 0,
        pageSize: 10,
        question:'',
      },
      total: 0,
      storeId: '',
      question:'',
      text: '点击检测偏差数据',
    }
  },

  mounted() {
    this.getList()
  },

  methods: {
    getList() {
      this.listLoading = true
      reviewAmount(this.listQuery).then(response => {
        this.list = response.data.data
        this.total = response.data.total
        this.listLoading = false
      })
    },
    search() {
      if(this.question == ''){
          this.question = 'question'
          this.text = '点击查看全部数据'
      }else{
          this.question = ''
          this.text = '点击检测偏差数据'
      }
      this.listQuery.storeId = this.storeId
      this.listQuery.question = this.question
      this.getList()
    }
  }

}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.app-container{
    .handle-content{
        .right{
            float: right;
            margin-bottom: 20px;
        }
    }
}
</style>
